package com.dd.machine.base.utils;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;

public class PDUtils {
	private PDUtils(){

	}
	public static PDUtils getInstance(){
		return new PDUtils();
	}
	public ProgressDialog progressDialog;
	public  void showProgressDialog(Context context, String title, String msg) {
		if ((progressDialog == null)) {
			progressDialog = ProgressDialog.show(context, title, msg);
			progressDialog.setCanceledOnTouchOutside(true);
			progressDialog.setOnDismissListener(new OnDismissListener() {
				@Override
				public void onDismiss(DialogInterface dialog) {
					if (progressDialog != null && progressDialog.isShowing()) {
						progressDialog.dismiss();
					}
					progressDialog = null;
				}
			});
		}
	}

	public boolean isShowing(){
		if(progressDialog != null && progressDialog.isShowing()){
			return true;
		}
		return false;
	}

	public  void closeProgressDialog() {
		if (progressDialog != null && progressDialog.isShowing()) {
			progressDialog.dismiss();
		}
		progressDialog = null;
	}
}